/*
THIS FILE IS PART OF THE >>ADRENALIN-3D-GRAFIC-ENGINE<<
for latest info visit http://www.creative-games.de

Copyright (c) 2008-2009 by Marco Schneider

This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License (LGPL) as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
License for more details.

*/

#ifndef __ADL_ADRENALIN_LOG_H__
#define __ADL_ADRENALIN_LOG_H__

#pragma region Include Section
#include <iostream>
#include <fstream>
#include "Defines.h"
#include "Singleton.h"
#include "../interfaces/ILog.h"
#pragma endregion

#define WIDEN2(x) L ## x
#define WIDEN(x) WIDEN2(x)
#define __WFILE__ WIDEN(__FILE__)	
#define __WFUNCTION__ WIDEN(__FUNCTION__)
#define WRITELOG(msg, type)	Log::Instance()->Write(msg, type, __WFILE__, __WFUNCTION__, __LINE__)

namespace Adrenalin
{
	class ADRENALIN_API Log : public Adrenalin::Singleton<Adrenalin::Log>, public Adrenalin::ILog
	{
		friend Adrenalin::Singleton<Adrenalin::Log>;
	private:
		Adrenalin::stringw				_fileName;
		std::basic_ofstream<wchar_t>	_logFile;
	private:
		Log();
		Adrenalin::stringw	Time();
		Adrenalin::stringw	ConvertType(ELogType type);
	public:
		void	Init(Adrenalin::stringw file);
		void	Close();
		void	Write(const Adrenalin::stringw& message, ELogType type, const Adrenalin::stringw& file, const Adrenalin::stringw& function, const unsigned long line);
		void	Write(const wchar_t* message, ELogType type, const Adrenalin::stringw& file, const Adrenalin::stringw& function, const unsigned long line);
		void	Write(const wchar_t* message, ELogType type);
	};
};//namespace

#endif